# This script transcodes a given video file to different GOP and QSCALES (2 for loops) and saves a log file. The logfile is used by gop_vs_fsize.py plotting script.

# If videos should be saved replace ffmpeg line with this:
# ffmpeg -i "$INPUTFILE" -y -qscale "$QSCALE" -an -g "$GOPSIZE" "$INPUTFILE""GOP$GOPSIZE-qscale$QSCALE"

# TO DO
# 	...

INPUTFILE="$1" # identify inputfile
LOGFILE="$2" # name logfile
OUTPUTFILE="temp/temp.avi" # wont really be used for anything

for QSCALE in 10 ; do
#	for GOPSIZE in 1 2 3 4 6 8 12 16 24 32 64 128 256 512; do # (approx 2 min pr. GOPSIZE) # Accurate
	for GOPSIZE in 1 2 4 8 16 32 64 128 256 512; do # (approx 2 min pr. GOPSIZE) # Quick
		ffmpeg -i "$INPUTFILE" -y -qscale "$QSCALE" -an -g "$GOPSIZE" "$OUTPUTFILE"
		echo "GOP = $GOPSIZE	Qscale = $QSCALE:" >> "$LOGFILE" # Note gop and qscale params in log
		stat -c %s "$OUTPUTFILE" >> "$LOGFILE" # Note filesize in log
		rm -f "GOP$GOPSIZE-qscale$QSCALE""$OUTPUTFILE" # Remove transcoded video
	done
done



